<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ title }}</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            margin: 0;
            padding: 20px;
            color: #333;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
        }
        .header {
            background-color: #f8f9fa;
            padding: 20px;
            border-radius: 5px;
            margin-bottom: 20px;
        }
        .summary {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }
        .summary-item {
            background-color: #fff;
            padding: 15px;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            text-align: center;
        }
        .summary-item h3 {
            margin: 0;
            color: #666;
        }
        .summary-item .value {
            font-size: 24px;
            font-weight: bold;
            margin: 10px 0;
        }
        .summary-item.success .value { color: #28a745; }
        .summary-item.warning .value { color: #ffc107; }
        .summary-item.danger .value { color: #dc3545; }
        .chart-container {
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            margin-bottom: 30px;
        }
        .chart {
            width: 100%;
            height: 300px;
            margin: 20px 0;
        }
        .response-times {
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            overflow: hidden;
        }
        .response-times table {
            width: 100%;
            border-collapse: collapse;
        }
        .response-times th,
        .response-times td {
            padding: 12px;
            text-align: left;
            border-bottom: 1px solid #dee2e6;
        }
        .response-times th {
            background-color: #f8f9fa;
            font-weight: bold;
        }
        .response-times tr:hover {
            background-color: #f8f9fa;
        }
        .timestamp {
            color: #666;
            font-size: 14px;
        }
        .metric {
            font-size: 14px;
            color: #666;
        }
        .metric .value {
            font-size: 18px;
            font-weight: bold;
            color: #333;
        }
    </style>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>{{ title }}</h1>
            <p class="timestamp">生成时间: {{ timestamp }}</p>
        </div>

        <div class="summary">
            <div class="summary-item">
                <h3>总请求数</h3>
                <div class="value">{{ summary.total_requests }}</div>
            </div>
            <div class="summary-item success">
                <h3>成功请求</h3>
                <div class="value">{{ summary.successful_requests }}</div>
            </div>
            <div class="summary-item danger">
                <h3>失败请求</h3>
                <div class="value">{{ summary.failed_requests }}</div>
            </div>
            <div class="summary-item">
                <h3>成功率</h3>
                <div class="value">
                    {{ "%.1f"|format(summary.successful_requests / summary.total_requests * 100 if summary.total_requests > 0 else 0) }}%
                </div>
            </div>
        </div>

        <div class="chart-container">
            <h2>响应时间分布</h2>
            <canvas id="responseTimeChart" class="chart"></canvas>
        </div>

        <div class="response-times">
            <h2>响应时间统计</h2>
            <table>
                <thead>
                    <tr>
                        <th>指标</th>
                        <th>值</th>
                        <th>说明</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>平均响应时间</td>
                        <td>{{ "%.3f"|format(summary.average_response_time) }}s</td>
                        <td>所有请求的平均响应时间</td>
                    </tr>
                    <tr>
                        <td>最小响应时间</td>
                        <td>{{ "%.3f"|format(summary.min_response_time) }}s</td>
                        <td>最快的请求响应时间</td>
                    </tr>
                    <tr>
                        <td>最大响应时间</td>
                        <td>{{ "%.3f"|format(summary.max_response_time) }}s</td>
                        <td>最慢的请求响应时间</td>
                    </tr>
                    <tr>
                        <td>P95响应时间</td>
                        <td>{{ "%.3f"|format(summary.p95_response_time) }}s</td>
                        <td>95%的请求响应时间低于此值</td>
                    </tr>
                    <tr>
                        <td>P99响应时间</td>
                        <td>{{ "%.3f"|format(summary.p99_response_time) }}s</td>
                        <td>99%的请求响应时间低于此值</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>

    <script>
        // 响应时间分布图表
        const ctx = document.getElementById('responseTimeChart').getContext('2d');
        new Chart(ctx, {
            type: 'line',
            data: {
                labels: {{ results.response_times.labels|tojson }},
                datasets: [{
                    label: '响应时间分布',
                    data: {{ results.response_times.data|tojson }},
                    borderColor: 'rgb(75, 192, 192)',
                    tension: 0.1
                }]
            },
            options: {
                responsive: true,
                scales: {
                    y: {
                        beginAtZero: true,
                        title: {
                            display: true,
                            text: '响应时间 (秒)'
                        }
                    },
                    x: {
                        title: {
                            display: true,
                            text: '请求数'
                        }
                    }
                }
            }
        });
    </script>
</body>
</html> 